USE [pos]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_SaleItem_Qty]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SaleItem] DROP CONSTRAINT [DF_SaleItem_Qty]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_SaleItem_Discount]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SaleItem] DROP CONSTRAINT [DF_SaleItem_Discount]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_SaleItem_Tax]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SaleItem] DROP CONSTRAINT [DF_SaleItem_Tax]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_SaleItem_CreatedOn]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[SaleItem] DROP CONSTRAINT [DF_SaleItem_CreatedOn]
END

GO

USE [pos]
GO

/****** Object:  Table [dbo].[SaleItem]    Script Date: 04/01/2012 16:33:22 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SaleItem]') AND type in (N'U'))
DROP TABLE [dbo].[SaleItem]
GO

USE [pos]
GO

/****** Object:  Table [dbo].[SaleItem]    Script Date: 04/01/2012 16:33:22 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[SaleItem](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Type] [nvarchar](10) NOT NULL,
	[Description] [nvarchar](max) NULL,
	[Qty] [int] NOT NULL,
	[Unit] [nvarchar](10) NOT NULL,
	[Price] [money] NOT NULL,
	[Discount] [money] NOT NULL,
	[Tax] [money] NOT NULL,
	[CreatedOn] [datetime] NOT NULL,
	[CreatedBy] [nvarchar](10) NOT NULL,
	[UpdatedOn] [datetime] NULL,
	[UpdatedBy] [nvarchar](10) NULL,
 CONSTRAINT [PK_SaleItem] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'running id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Id'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'sale item name' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Name'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'sale item type:food or beverage' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Type'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'food description' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Description'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'sale quantity per item' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Qty'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'item measurable unit' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Unit'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'sale price' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Price'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'item discount' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Discount'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'tax amount' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'Tax'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'creation date' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'CreatedOn'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'creator userid' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'CreatedBy'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'last update date' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'UpdatedOn'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'userid who last updated this record' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SaleItem', @level2type=N'COLUMN',@level2name=N'UpdatedBy'
GO

ALTER TABLE [dbo].[SaleItem] ADD  CONSTRAINT [DF_SaleItem_Qty]  DEFAULT ((1)) FOR [Qty]
GO

ALTER TABLE [dbo].[SaleItem] ADD  CONSTRAINT [DF_SaleItem_Discount]  DEFAULT ((0)) FOR [Discount]
GO

ALTER TABLE [dbo].[SaleItem] ADD  CONSTRAINT [DF_SaleItem_Tax]  DEFAULT ((0)) FOR [Tax]
GO

ALTER TABLE [dbo].[SaleItem] ADD  CONSTRAINT [DF_SaleItem_CreatedOn]  DEFAULT (getdate()) FOR [CreatedOn]
GO

